<?php
/*
 * Created on 22/04/2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 class RuleSetDao {
     
     function loadRuleSets() {
        $array = array ();
        $rs = executeQuery("select distinct id, short_name, long_name from rule_sets rs join races_rule_sets rrs on rs.id=rrs.fk_rule_id");
        while ($row = mysql_fetch_row($rs)) {
            $ruleSet = new RuleSet($row[0], $row[1], $row[2]);
            $array[$ruleSet->getId()] = $ruleSet;
        }

        return $array;
     }
     
     function findRaceIdsForRuleSet($ruleSet) {
        $array = array ();
        $rs = executeQuery("SELECT rrs.fk_race_id, r.name FROM races_rule_sets rrs " .
        		"join races r on rrs.fk_race_id=r.race_id WHERE fk_rule_id=" . $ruleSet->getId() . " order by 2");
        while ($row = mysql_fetch_row($rs)) {
        	array_push($array, $row[0]);
        }
        return $array;
     }
 }
?>
